#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    int n = 0;
    while (cin >> n)
    {
        vector<int> nums(n, 0);
        int maxLen = 0;
        vector<int> dp(n, 1);
        for (int i = 0; i < n; ++i)
        {
            cin >> nums[i];
            for (int j = i - 1; j >= 0; --j)
            {
                if (nums[j] < nums[i])
                    dp[i] = max(dp[i], dp[j] + 1);
            }
            maxLen = max(dp[i], maxLen);
        }
        cout << maxLen << endl;
    }
}